/*
 * @Description: class
 * @Author: rendc
 * @Date: 2024-10-09 14:45:24
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-09 15:10:33
 */

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

/**
 * Test5_3
 */
public class Test5_3 {

  public static void main(String[] args) {
    Teacher t1 = new Teacher(1L, "t1", 21);
    Teacher t2 = new Teacher(2L, "t2", 22);
    Teacher t3 = new Teacher(3L, "t3", 24);
    Teacher t4 = new Teacher(4L, "t4", 23);
    // System.out.println(t1);
    // 将对象保存在TreeSet集合中
    Set<Teacher> set = new TreeSet<>();
    Map
    set.add(t1);
    set.add(t2);
    set.add(t3);
    set.add(t4);
    set.add(new Teacher(5L, "t3", 24));
    set.add(new Teacher(5L, "t4", 24));
    set.add(new Teacher(7L, "t6", 26));
    set.add(new Teacher(6L, "t6", 26));
    // 并且排序
    // System.out.println(set);
    // 遍历集合
    for (Teacher teacher : set) {
      System.out.println(teacher);
    }

    // Set<Teacher> set1 = new TreeSet<>(
    // new Comparator<T>() {
    // public int compare(T o1, T o2) {
    // Teacher t1 = (Teacher)o1;
    // Teacher t2 = (Teacher)o2;
    // if (t1.getName().equals(t2.getName())) {
    // if (t1.getAge() == t2.getAge()) {
    // // ...
    // }
    // }
    // // return 1;
    // };
    // };
    // );
  }
}